//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Validation Application Block
//===============================================================================

using System;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace EntLibContrib.Validation.Validators
{
	/// <summary>
	/// Enum Defined Validator attribute
	/// </summary>
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true, Inherited = false)]
	public sealed class EnumDefinedValidatorAttribute : ValueValidatorAttribute
	{
		#region Protected Methods
		/// <summary>
		/// Creates the <see cref="EnumDefinedValidator"/> described by the attribute object.
		/// </summary>
		/// <param name="targetType">The type of object that will be validated by the validator.</param>
		/// <remarks>This operation must be overriden by subclasses.</remarks>
		/// <returns>The created <see cref="EnumDefinedValidator"/>.</returns>
		protected override Validator DoCreateValidator(Type targetType)
		{
			return new EnumDefinedValidator(Negated);
		}
		#endregion
	}
}
